package com.hushan.elevator.dao;

import com.hushan.elevator.model.UserDept;
import com.hushan.elevator.model.UserDeptPK;
//import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface UserDeptRepository  extends JpaRepository<UserDept, UserDeptPK> {
    @Modifying
    @Transactional
    @Query(value = "UPDATE auth_user_dept " +
            "SET dept_id = :newDeptId " +
            "WHERE user_id = :userId AND dept_id = :deptId;",nativeQuery = true)
    void updateUserDept(Integer userId, Integer deptId, Integer newDeptId);
}
